1 using UnityEngine;
2 using
System.Collections;
3
4 public
class BossMoving : MonoBehaviour
5 {
6     
public Transform[] bossPoints;
7     
public float speed;
8     Transform nextPoint;
9     Rigidbody rb;
10     Random rand;
11
12
13     
void Awake ()
14     {
15         rb = GetComponent<Rigidbody>();
16     }
17
18     
void Start()
19     {
20         nextPoint = bossPoints[
0];
21         StartCoroutine(
"Moving");
22     }
23
24
25     
void Update()
26     {
27         transform.position = Vector3.MoveTowards(transform.position, nextPoint.position, speed * Time.deltaTime);
28         
//transform.position = Vector3.MoveTowards(transform.position, player.position, speed * Time.deltaTime);
29     }
30
31     IEnumerator Moving()
32     {
33         
yield return new WaitForSeconds(2);
34         nextPoint = bossPoints[
3];
35         
yield return new WaitForSeconds(2);
36         
while (true)
37         {
38             nextPoint = bossPoints[rand.Randomization_1(
0, 20, 40, 60, 73, 86, 99)];
39             
yield return new WaitForSeconds(6);
40         }
41     }
42 }


transform.position = Vector3.MoveTowards(transform.position, player.position, speed * Time.deltaTime);




Trò chơi game bắn súng đơn giản trong UNITY Engine 23.621 lượt xem

Gõ tìm kiếm nhanh...